#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsEllipseItem>
#include <QGraphicsTextItem>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QRadioButton>
#include "linkedlist.h"
#include "animatedrectitem.h"
#include "QDebug"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void createOrAddNode();
    void showIntersection();
    void showUnion();
    void showDifference();
    void displayList(LinkedList* list, QGraphicsScene* scene);
    void handleNodeValueChanged(int newValue, Node* nodePointer); // 添加槽函数声明
    void handleViewSelection();

private:
    Ui::MainWindow *ui;
    LinkedList *list1;
    LinkedList *list2;
    int listCount = 0;

    QPushButton* createButton;
    QPushButton* intersectionButton;
    QPushButton* unionButton;
    QPushButton* differenceButton;
    QLineEdit* lineEdit;
    QLabel* resultLabel;

    QGraphicsView* view1;
    QGraphicsView* view2;
    QGraphicsView* resultView;
    QGraphicsScene* scene1;
    QGraphicsScene* scene2;
    QGraphicsScene* resultScene;
    QRadioButton* selectView1;
    QRadioButton* selectView2;

    void clearScene(QGraphicsScene* scene);
    void addNodeToScene(int value, int x, int y, Node* nodePointer, QGraphicsScene* scene);
    void clearAll();
};

#endif // MAINWINDOW_H
